package main

import "strconv"

func summaryRanges(nums []int) []string {
	result := make([]string, 0)
	last := 0
	now := 0
	for now < len(nums) {
		last = now
		now++
		for ; now < len(nums); now++ {
			if nums[now-1]+1 != nums[now] {
				break
			}
		}

		if now-last == 1 {
			result = append(result, strconv.Itoa(nums[last]))
		} else {
			result = append(result, strconv.Itoa(nums[last])+"->"+strconv.Itoa(nums[now-1]))
		}

	}

	return result
}
